package com.phenix.mvp.aop;

import android.util.LruCache;

/**
 * @author zhouphenix on 2016-12-25.
 */

public class MemoryCacheManager {
    private MemoryCacheManager(){}

    private static final class Holder{
        public static final MemoryCacheManager mInstance = new MemoryCacheManager();
    }
    public static MemoryCacheManager getInstance(){return Holder.mInstance;}

    private final static int mCacheSize = (int)(Runtime.getRuntime().maxMemory()/1024) / 8;

    private final static LruCache<String, Object> mMemoryCache = new LruCache<>(mCacheSize);

    public static void add(String key, Object value){ mMemoryCache.put(key,value);}

    public static Object get(String key){return mMemoryCache.get(key);}
}
